package com.qf.sy2103.fmmall.api.controller;

import com.qf.sy2103.common.vo.ResultVO;
import com.qf.sy2103.fmmall.beans.entity.ShoppingCart;
import com.qf.sy2103.fmmall.service.ShoppingCartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("/shopcart")
public class ShopCartController {

    @Autowired
    private ShoppingCartService shoppingCartService;

    @PostMapping("/add")
    public ResultVO add( @RequestBody ShoppingCart shoppingCart){

        return shoppingCartService.addShopCart(shoppingCart);

    }


    @GetMapping("/list")
    public ResultVO list( Integer userId){

        return shoppingCartService.listByUserId(userId);

    }


    @PutMapping("/update/{cid}/{cnum}")
    public ResultVO update(@PathVariable("cid") Integer cid, @PathVariable("cnum") Integer cnum){

        return shoppingCartService.update(cid,cnum);

    }


    @GetMapping("/listbycids")
    public ResultVO listbycids(String cids){

        return shoppingCartService.listbycids(cids);

    }


}
